package com.xca.photogallery.views;

import android.widget.TextView;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.xca.photogallery.R;
import com.xca.photogallery.adapter.AvatarFirstAdapter;
import com.xca.photogallery.adapter.DayImgAdapter;
import com.xca.photogallery.base.BaseActivity;
import com.xca.photogallery.contract.AvatarContact;
import com.xca.photogallery.entity.DayAvatar;
import com.xca.photogallery.presenter.AvatarPresenter;

import java.util.ArrayList;
import java.util.List;

public class AvatarListActivity extends BaseActivity implements AvatarContact.AvatarView{
    private TextView textView ;
    private RecyclerView recyclerView ;
    private AvatarContact.AvatarPresenter mPresenter ;
    private AvatarFirstAdapter adapter ;
    private List<DayAvatar.AvatarFirstData> mList ;
    @Override
    public int getLayoutId() {
        return R.layout.day_image;
    }

    @Override
    public void init() {
        textView = findViewById(R.id.mTitle);
        recyclerView = findViewById(R.id.dListView);
        textView.setText("米哈游头像库");
        mPresenter = new AvatarPresenter(this , this);
        mPresenter.getData();
        recyclerView.setLayoutManager(new GridLayoutManager(this,2));
        mList = new ArrayList<>();
        adapter = new AvatarFirstAdapter( mList , this);
        recyclerView.setAdapter(adapter);
    }

    @Override
    public void showData(DayAvatar data) {
        mList = data.getResult() ;
        adapter.updateData(mList);
    }
}
